package ldh.im.fxgui.controller;

import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;

public class SettingController implements Initializable {

    @FXML private StageControlController stagePaneController;
    @FXML private Pane movablePane;
    @FXML private Pane settingLeftPane;

    public void setStage(Stage stage) {
        stagePaneController.setStage(stage);
    }

    public Pane getMovablePane() {
        return movablePane;
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        stagePaneController.hideMax();
        addLeftPaneActive();
    }

    private void addLeftPaneActive() {
        settingLeftPane.getChildren().forEach(n->{
           n.addEventFilter(MouseEvent.MOUSE_CLICKED, e->{
               clearActiveStyle();
               n.getStyleClass().add("active");
           });
        });
    }

    private void clearActiveStyle() {
        settingLeftPane.getChildren().forEach(n->n.getStyleClass().remove("active"));
    }
}
